package com.wealth.scsj.b_app.view.fragment.commentmodel;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import com.google.gson.Gson;
import com.wealth.scsj.b_app.R;
import com.wealth.scsj.b_app.adapter.LeftCommAdapter;
import com.wealth.scsj.b_app.adapter.RightCommAdapter;
import com.wealth.scsj.b_app.base.UserEvaluateBase;
import com.wealth.scsj.b_app.bean.GetEvaluationNumBean;
import com.wealth.scsj.b_app.bean.RightCommBean;
import com.wealth.scsj.b_app.bean.UserEvaluateListBean;
import com.wealth.scsj.b_app.bean.UserRequestEvaluateBean;
import com.wealth.scsj.b_app.presenter.UserEvaluatePresenter;
import com.wealth.scsj.b_app.view.activity.BaseActivity;
import com.wealth.scsj.b_app.view.fragment.basemodel.BaseFragment;

import java.util.ArrayList;
import java.util.List;

import okhttp3.RequestBody;

/**
 * Created by Administrator on 2018/7/26.
 * 未回复差评
 */

public class NoAndBadCommentFragment extends BaseFragment implements UserEvaluateBase.IView{
    private RecyclerView mRecyclerView;

    private LeftCommAdapter adapter;
    private LinearLayout leftHeadLayout;
    private UserEvaluatePresenter userEvaluatePresenter;
    private List<UserEvaluateListBean.DataBean> leftCommBeanList;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_left_comm, null);
        initView(view, null);
        initListener();
        initData();
        return view;
    }
    @Override
    protected void initView(View view, Bundle savedInstanceState) {
        mRecyclerView= view.findViewById(R.id.comment_list_rv);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(getHoldingActivity()));
        leftHeadLayout= view.findViewById(R.id.left_head_layout);
        leftHeadLayout.setVisibility(View.GONE);
        userEvaluatePresenter= new UserEvaluatePresenter(this);
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData() {
        UserRequestEvaluateBean userRequestEvaluateBean= new UserRequestEvaluateBean();
        userRequestEvaluateBean.setStoreId("c1b9d0ec-749d-11e8-afb7-70106fb15682");
        userRequestEvaluateBean.setType(1);
        userRequestEvaluateBean.setHeightFrameCapture(60);
        userRequestEvaluateBean.setWidthFrameCapture(60);
        UserRequestEvaluateBean.PageInfoBean pageInfoBean= new UserRequestEvaluateBean.PageInfoBean();
        pageInfoBean.setPageNum(10);
        pageInfoBean.setPageSize(1);
        Gson gson = new Gson();
        String obj = gson.toJson(userRequestEvaluateBean);
        RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), obj);
        userEvaluatePresenter.deliverData(body);
    }

    @Override
    protected int getLayoutId() {
        return 0;
    }

    @Override
    public void showSuccessMsg(String s, UserEvaluateListBean userEvaluateListBean) {

        leftCommBeanList =userEvaluateListBean.getData();
        adapter = new LeftCommAdapter(getHoldingActivity(),leftCommBeanList);
        mRecyclerView.setAdapter(adapter);
    }

    @Override
    public void showEvaluationNumSuccessMsg(String s, GetEvaluationNumBean getEvaluationNumBean) {

    }

    @Override
    public void showErrorMsg(String s) {

    }
}
